package com.example.leetdemo.process;

public class Solution862 {

    public int shortestSubarray(int[] nums, int k) {

        int[] pre = new int[nums.length];
        pre[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            pre[i] = pre[i - 1] + nums[i];
        }
        for (int i = 1; i <= nums.length; i++) {
            int now = 0;
            for (int j = 0; j < i; j++) {
                now += nums[j];
            }
            if (now >= k) {
                return i;
            }
            for (int l = i; l < nums.length; l++) {
                now += nums[l];
                now -= nums[l - i];
                if (now >= k) {
                    return i;
                }
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Solution862 solution862 = new Solution862();
        System.err.println(solution862.shortestSubarray(new int[] {1}, 1));
    }
}
